﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowAttachments.aspx.cs" Inherits="FBKPI.Tools.ShowAttachments.ShowAttachments" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>KPI Child Attachments</title>
    <script type="text/javascript" src="../../Scripts/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery-ui-1.8.23.min.js"></script>
    <script type="text/javascript" src="../../Scripts/jquery.json-2.3.min.js"></script>
    <script type="text/javascript" src="../../Scripts/Datatables/jquery.dataTables.js"></script>
    <link href="../../Styles/style.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/DataTables/css/demo_table_jui.css" rel="Stylesheet" />
    <link href="../../Content/themes/base/jquery.ui.all.css" rel="Stylesheet" />
    <script type="text/javascript" src="../../Scripts/Datatables/jquery.dataTables.FixedColumns.js"></script>                   

    <script type="text/javascript">
        $(document).ready(function () {

            var oTable = $("#timeline").dataTable({
                "oLanguage": {
                    "sZeroRecords": "No records to display",
                    "sSearch": "Search"
                },
                "sScrollX": "100%",
                "sScrollXInner": "200%",
                "bScrollCollapse": false,
                "bSort": false,
                "bPaginate": false,
                "bAutoWidth": false,
                "bProcessing": true,
                "bServerSide": true,
                "bDestroy": true,
                "bJQueryUI": true,
                "fnInitComplete": function () {
                    new FixedColumns(oTable, {
                        "iLeftColumns": 0,
                        "iLeftWidth": "0"
                    });
                },
                "fnServerData": function (sSource, aoData, fnCallback) {
                    $.ajax({
                        "dataType": 'json',
                        "type": "GET",
                        "url": "../../Serializer/KPIChildAttachmentSerializer.ashx?User=" + $("#txt_userid").val() + "&Year=" + $("#txt_year").val() + "&KPI=" + $("#txt_kpiid").val(),
                        "data": aoData,
                        "success": fnCallback
                    });
                },
                "aoColumns": [{
                    "mData": "Jan"
                }, {
                    "mData": "Feb"
                }, {
                    "mData": "Mar"
                }, {
                    "mData": "Apr"
                }, {
                    "mData": "May"
                }, {
                    "mData": "Jun"
                }, {
                    "mData": "Jul"
                }, {
                    "mData": "Aug"
                }, {
                    "mData": "Sep"
                }, {
                    "mData": "Oct"
                }, {
                    "mData": "Nov"
                }, {
                    "mData": "Dec"
                }, ],
                "aoColumnDefs": [{
                    "fnRender": function (oObj) {

                        if (oObj.aData["Mar"] != '') {
                            var files = oObj.aData["Mar"].toString().split("\n");
                            var retVal = "";

                            for (i = 0; i < files.length; i++) {
                                if (files[i].indexOf('..') >= 0) {
                                    var filename = files[i].split("/");
                                    retVal += "<a href=\"#\" onclick=\"GetAttachment('" + files[i] + "')\">" + filename[filename.length - 1] + "</a></br>";
                                }
                            }
                        }
                        return retVal;
                    },
                    "aTargets": [2]
                }]
            });
        });

        function GetAttachment(file) {
            //alert(file);
            document.location = file;
            return false;
        }
    </script>
    <style>
        .fg-toolbar{display: none;}
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div class="customPageTitle">Attachment List <input type="hidden" id="txt_kpiid" runat="server"/><input type="hidden" id="txt_userid" runat="server"/><input type="hidden" id="txt_year" runat="server"/></div><br />
        <div class="ui-widget-content">
            <table cellpadding="0" cellspacing="0" class="display" id="timeline">
                <thead>
                    <tr>
                        <th>
                            Jan
                        </th>
                        <th>
                            Feb
                        </th>
                        <th>
                            Mar
                        </th>
                        <th>
                            Apr
                        </th>
                        <th>
                            May
                        </th>
                        <th>
                            Jun
                        </th>
                        <th>
                            Jul
                        </th>
                        <th>
                            Aug
                        </th>
                        <th>
                            Sep
                        </th>
                        <th>
                            Oct
                        </th>
                        <th>
                            Nov
                        </th>
                        <th>
                            Dec
                        </th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>       
        </div>
    </div>
    </form>
</body>
</html>
